package com.education.model.dto;

import com.education.common.constants.EnumConstants;
import com.education.common.util.ObjectUtils;
import com.education.model.entity.SystemAdmin;
import com.education.model.entity.SystemMenu;
import com.education.model.entity.SystemRole;
import lombok.Data;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author 余一
 * @date 2021/9/18  15:26
 */
@Data
public class AdminUserSession extends BaseDto{
    private String sessionId;
    private String token;
    private SystemAdmin systemAdmin;  //存储管理员信息
    private List<SystemRole> roleList;
    private List<SystemMenu> menuList;
    private List<MenuTree> menuTreeList;//树形菜单列表
    private Set<String> permissionList = new HashSet<>();

    public AdminUserSession(SystemAdmin systemAdmin) {
        this.systemAdmin = systemAdmin;
    }

    public Integer getAdminId(){
        return systemAdmin.getId();
    }

    /**
     * 判断是否超级管理员
     * @return
     */
    public boolean isSuperAdmin(){
        if (ObjectUtils.isEmpty(systemAdmin)) {
            return false;
        }
        return systemAdmin.getSuperFlag() == EnumConstants.Flag.YES.getValue();
    }
}
